package com.lyf.lottery.service.impl;


import com.lyf.lottery.dao.mapper.OptActivityBlindBoxRecordMapper;
import com.lyf.lottery.model.po.OptActivityBlindBoxRecord;
import com.lyf.lottery.model.req.OptActivityBlindBoxRecordQuery;
import com.lyf.lottery.service.OptActivityBlindBoxRecordService;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.io.Serializable;

/**
 * OptActivityBlindBoxRecord service
 * @author lyf
 **/
@Slf4j
@Service
public class OptActivityBlindBoxRecordServiceImpl implements OptActivityBlindBoxRecordService {

    @Resource
    private  OptActivityBlindBoxRecordMapper optActivityBlindBoxRecordMapper;

    /**
     * 分页查询
     * @param query 查询条件
     * @date 2020/12/25
     * @return PageInfo
     */
    @Override
    public PageInfo<OptActivityBlindBoxRecord> selectPage(OptActivityBlindBoxRecordQuery query){
        PageHelper.startPage(query.getPageNum(),query.getPageSize());
        List<OptActivityBlindBoxRecord> list = optActivityBlindBoxRecordMapper.selectList(query);
        return new PageInfo<>(list);
    }

    /**
     * 插入数据
     * @param entity entity
     * @date 2020/12/25
     * @return com.lyf.lottery.entity.OptActivityBlindBoxRecord
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public OptActivityBlindBoxRecord insert(OptActivityBlindBoxRecord entity){
        optActivityBlindBoxRecordMapper.insert(entity);
        return entity;
     }

    /**
     * 修改数据
     * @param entity entity
     * @date 2020/12/25
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void update(OptActivityBlindBoxRecord entity){
        optActivityBlindBoxRecordMapper.updateSelective(entity);
    }
    /**
     * 获取详情
     * @param id 主键ID
     * @date 2020/12/25
     * @return com.lyf.lottery.entity.OptActivityBlindBoxRecord
     */
    @Override
    public OptActivityBlindBoxRecord selectById(Serializable id) {
        OptActivityBlindBoxRecord optActivityBlindBoxRecord = optActivityBlindBoxRecordMapper.selectById(id);
        return optActivityBlindBoxRecord;
    }

}
